<?php

require_once ROOT_DIR.'models/TodoList.php';

/**
 * Tries to create and save an object of the todo list model and echos the resulting view.
 * @param string $name
 * @param string $description
 */
function newList($name, $description){
	$list = new TodoList($name, $description, $_SESSION['USER_ID']);
	if($list->saveToDB()){
		$res = new ResultJSON(false, session_id());
		$res->addItem('lID', $list->getID());
		echo $res->renderView();
	} else {
		$res = new ResultJSON(true, session_id(), ERROR_ACTION_FAILED);
		echo $res->renderView();
	}
}

?>